package cn.tm.liu.mode.composite.demo1;

import java.util.Date;

/**
 * @author Marvin.L
 * @description
 * @date 2022.04.09 14.29
 */
public class Main {
    public static void main(String[] args) {
        Employee CEO = new Employee("John", "CEO", 30000);

        Employee headSales = new Employee("Robert", "Head Sales", 20000);
        Employee headMarketing = new Employee("Michel", "Head Marketing", 20000);

        Employee clerk1 = new Employee("Laura", "Marketing", 10000);
        Employee clerk2 = new Employee("Bob", "Marketing", 10000);

        Employee salesExecutive1 = new Employee("Richard", "Sales", 10000);
        Employee salesExecutive2 = new Employee("Rob", "Sales", 10000);

        CEO.add(headSales);
        CEO.add(headMarketing);

        headSales.add(salesExecutive1);
        headSales.add(salesExecutive2);

        headMarketing.add(clerk1);
        headMarketing.add(clerk2);

        //打印该组织的所有员工
        System.out.println(format('=', 76) + " CEO");
        CEO.print();
        System.out.println(format('=', 76) + " headSales");
        headSales.print();

        System.out.println(format('=', 76));
        Date date = new Date();
        String fullTime = String.format("%tF %tT%n", date, date);
        System.out.print(fullTime);
    }

    private static String format(char fill, int len) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < len; i++) {
            sb.append(fill);
        }
        return sb.toString();
    }
}
